<?php

// +----------------------------------------------------------------------
// | 主页
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 微尘 <yicmf@qq.com>
// +----------------------------------------------------------------------

namespace app\controller\pos;

use app\common\controller\Base;
use app\event\app\Ctrip;
use app\event\app\ExchangeCoupon;
use app\event\app\ExchangeCoupon as ExchangeCouponEvent;
use app\event\app\Jd;
use app\event\app\Jd as JdEvent;
use app\event\app\Meituan;
use app\event\app\Mt;
use app\event\app\Pdd;
use app\event\app\Tbk;
use app\event\app\ThirdRecharge;
use app\event\app\ThirdRecharge as ThirdRechargeEvent;
use app\event\app\Tui;
use app\event\file\Attachment;
use app\event\file\Image;
use app\event\im\Robot as RobotEvent;
use app\event\index\Share as ShareEvent;
use app\event\index\Task;
use app\event\pay\Bill as BillEvent;
use app\event\pay\PointOrder;
use app\event\pos\Pos as PosEvent;
use app\event\pos\PosOrder as PosOrderEvent;
use app\event\pos\PosTrade as PosTradeEvent;
use app\event\store\Store as StoreEvent;
use app\event\ucenter\IpPool;
use app\event\ucenter\Notice as NoticeEvent;
use app\event\ucenter\User as UserEvent;
use app\model\app\GameOrder;
use app\model\app\JdPid;
use app\model\app\PddGood as PddGoodModel;
use app\model\app\TbkPid;
use app\model\app\ThirdRecharge as ThirdRechargeModel;
use app\model\app\ThirdRechargeOrder;
use app\model\pay\Pay;
use app\model\pos\Pos;
use app\model\pos\PosTrade;
use app\model\ucenter\IpPool as IpPoolModel;
use app\model\ucenter\User;
use app\model\ucenter\User as UserModel;
use app\event\im\Chat as ChatEvent;
use app\model\ucenter\UserCash;
use app\model\ucenter\UserMoneyLog;
use app\model\ucenter\UserMoneyLog as UserMoneyLogModel;
use app\model\ucenter\UserOauth;
use app\model\wechat\WechatFans;
use app\model\wechat\WechatReply as WechatReplyModel;
use Firebase\JWT\JWK;
use Firebase\JWT\JWT;
use Justmd5\PinDuoDuo\PinDuoDuo;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Log;
use think\facade\Validate;
use think\File;
use Topsdk\Topapi\Ability2138\Ability2138;
use Topsdk\Topapi\Ability369\Ability369;
use Topsdk\Topapi\Ability369\Request\TaobaoTbkDgOptimusPromotionRequest;
use Topsdk\Topapi\Ability370\Request\TaobaoTbkDgMaterialTemporaryOptionalRequest;
use Topsdk\Topapi\Ability374\Ability374;
use Topsdk\Topapi\Ability374\Request\TaobaoTbkActivityInfoGetRequest;
use Topsdk\Topapi\Defaultability\Defaultability;
use wechat\official_account\Menu;
use wechat\official_account\Qrcode;
use wechat\official_account\Template as TemplateOfficial;
use wechat\official_account\User as UserOfficial;
use yicmf\tools\FlowSn;
use yicmf\tools\HttpService;
use Topsdk\Topapi\TopApiClient;
use Topsdk\Topapi\Ability370\Request\TaobaoTbkShopGetRequest;
use Topsdk\Topapi\Ability2138\Request\TaobaoTbkDgNewuserOrderGetRequest;
use Topsdk\Topapi\Ability370\Ability370;


class Index extends Common
{

    protected function initialize()
    {
        parent::initialize();
    }


    public function app()
    {
        return $this->fetch('index/index');
    }

    public function index()
    {
        return $this->fetch();
//
//        $re= UserEvent::f3BuserCheck();
//        dump($re);
//
//        return '1';
////        return $this->fetch();
//
//
//        $trade = User::where('id',1)->find();
//
//
//        dump($trade->moneys->toArray());
//
//        exit();
//        $trade = PosTrade::find(1982);
//        $pos = Pos::where('id',$trade['pos_id'])->find();
//
//        dump($trade->toArray());
//        dump($pos->toArray());
//
//        $event = new PosTradeEvent();
//        $re = $event->trade($trade,$pos);
//        dump($re);
//
//        exit();
//        if ($re['code'] != 0)
//        {
//            throw new Exception($re['message']);
//        }
//
//        $e = new PosEvent();
//        //终端返现
//        $pos = Pos::find(1097);
//
//        dump($pos->toArray());
//
//        return;
//        exit();

//
//        alipay_transfer(time(),0.01,'lilwil@163.com','刘伟');
//
//            exit();
//        $e = new PosEvent();
//        //终端返现
//        $re = $e->payback();
//
//        $log = config('log');
//        $log['default'] = 'task';
//
//        config($log,'log');
//
//        dump(config('log'));
//        $file = public_path().'aa.zip';
//
//        $file = new File($file);
//
//        dump(MD5_file($file));
//        $file = new \SplFileInfo($file);
//        dump($file);
//        halt($file);
        // 代理结算
//        BillEvent::agentMonth();
//        $pay = Pay::where('id',27)->find();
//
//        $event = new PosOrderEvent();
//        $event->pay($pay);

//        Cache::set('tips_service_say_21_1',12,10);

//        $m = Db::name('menu')->select();
//        foreach ($m as $index => $item) {
//            $u = [];
////            $u['controller'] = $item['module'].'/'. str_replace('.','/',$item['controller']);
//            $u['url'] = str_replace('.','/',$item['url']);
////            $u['module'] = '';
//            Db::name('menu')->where('id',$item['id'])->update($u);
//        }
        return 'ok';
    }


    public function test()
    {


        $jd = new JdEvent();
        $re = $jd->getOrder(3, strtotime('2025-02-08 21:30:13'), 1800);

        halt($re);
        ini_set('memory_limit', '512M');

        set_time_limit(1000);
        $event = new ShareEvent();
        $data = $event->autoBuild();


        dump($data);
        return;
        $order = ThirdRechargeOrder::where('id',1179)->find();

        // 失败 BFwl_nRGEbsr86f1Gc833kuf06GCQVkIMqUem3vsO9M


        $oa_data = [
            'number2' => ['value' => $order['template'], 'color' => '#000000'],
            'amount3' => ['value' => $order['all_amount'], 'color' => '#000000'],
            'thing5' => ['value' => $order['remark']?:'失败', 'color' => '#000000'],
            'thing7' => ['value' => $order['name'], 'color' => '#000000'],
            'time11' => ['value' => $order['pay_time'], 'color' => '#000000'],
        ];
        $account['token'] = 'yunfuye1';
        $account['encoding_aes_key'] = 'BkrUUPz9IgfERTRXmwiIf0RSir4ONBku64EufsZ9EE2';
        $account['app_secret'] = 'cbdd44c7d119c8b4dd51b74c3030aa75';
        $account['app_id'] = 'wxd4cc6bfc61b75cc5';
        $oa = new TemplateOfficial();
        $oa->initAccount($account);
        $fan = WechatFans::where('id', 1)->find();

        $re = $oa->send($fan['openid'], 'BFwl_nRGEbsr86f1Gc833kuf06GCQVkIMqUem3vsO9M', $oa_data, '');


        dump($re);
        exit();
        $fasn = WechatFans::where('status',1)->whereNull('user_id')->select();



        foreach ($fasn as $k => $v) {


            $oauth = UserOauth::where('union_id',$v['unionid'])->find();

            if ($oauth && $oauth['user_id'])
            {
                $v['user_id'] = $oauth['user_id'];
                $v->save();
            }
        }

        return;



        $account['token'] = 'yunfuye1';
        $account['encoding_aes_key'] = 'BkrUUPz9IgfERTRXmwiIf0RSir4ONBku64EufsZ9EE2';
        $account['app_secret'] = 'cbdd44c7d119c8b4dd51b74c3030aa75';
        $account['app_id'] = 'wxd4cc6bfc61b75cc5';


        $qr = new Qrcode();
        $qr->initAccount($account);
        $re = $qr->qrcodeCreate('life_825',3600) ;

        dump($re);exit();

        $UserOfficial = new UserOfficial();
        $UserOfficial->initAccount($account);

        $ids = WechatFans::where('id','>',0)->whereNull('sex')->limit(99)->column('openid');

//        dump($ids);

        $user = $UserOfficial->userInfoBatchGet($ids);

        foreach ($user['user_info_list'] as $k => $v) {

            $fas = WechatFans::where('openid',$v['openid'])->find();
            if ($fas)
            {
                $fas['language'] = $v['language'];
                $fas['sex'] = $v['sex'];
                $fas['subscribe_time'] = time_format($v['subscribe_time']);
                $fas['subscribe_scene'] = $v['subscribe_scene'];
                $fas['unionid'] = $v['unionid'];
                $fas->save();
            }

        }
        dump($user['user_info_list']);
        exit();

//        $user = $UserOfficial->userGet();

//        $all= [];
//        foreach ($user['data']['openid'] as $k => $v) {
//
//
//            if (!WechatFans::where('openid',$v)->find())
//            {
//                $all[] = ['openid'=>$v];
//            }
//        }
//        $f = new WechatFans();
//        $f->saveAll($all);
        dump($all);exit();
        halt($user);

        $user = UserModel::select();


        foreach ($user as $item) {
            $item['share_code'] = $item['shareCode'];
            $item->save();
        }

        //000006026203616792-991

        for ($i = 7000051; $i < 7000101; $i++) {
//            dump('000006026203616'.$i);
           echo'00007902C1243'.$i.'<br>';
        }

        exit();

        $user = UserModel::find(16006);
        $event = new ShareEvent();
        $data = $event->autoBuild();


        dump($data);
        return 'ok';
        $param['push_clientid'] = '1ba8a6509bfa7453428d438ed0fc764f';
        $param['title'] = 'time'.time_format();
        $param['content'] = 'ctime'.time_format();
        $param['content_available'] = 0;
        $param['sound'] = 'silence';
        $param['payload'] = ['page'=>'d/as/a','test'=>'dsaa'];
        $token = HttpService::post('http://v3.uniapp.yunfuye.com/unipush', json_encode($param));

        dump($token);
        exit();
        $image = new Attachment();

        dump($image->generateZip(public_path().'upload/index/'));

        return;

            $data = [
//            'bizLine'=>5,
//                'platform'=>2,
                'bizLine'=>3,
                'linkType'=>1,
                'sid'=>'a0112221',
//            'bizLine'=>1,
                'text'=>'http://i.meituan.com/awp/bepfe/dt-i-hotel-c/index.html'
            ];;
        $mt = new Meituan();
// 商品查询接口
        $url = 'https://media.meituan.com/cps_open/common/api/v1/get_referral_link';
        $config = [
            'method' => 'POST',
            'data' => $data,
            'url' => $url
        ];
        $header = $mt->getSignHeaders($config);

        dump($header);

        $res = $mt->curlPost($url, $data, 5, $header,'json');

        $res = json_decode($res, true);

//
//        // 调用接口
//        $data = [
////            'bizLine'=>5,
//            'platform'=>2,
//            'bizLine'=>3,
//            'sid'=>'a0112221',
////            'bizLine'=>1,
//            'searchText'=>'四季抗病毒合剂120ml'
//        ];
//        $mt = new Meituan();
//// 商品查询接口
//        $url = 'https://media.meituan.com/cps_open/common/api/v1/query_coupon';
//        $config = [
//            'method' => 'POST',
//            'data' => $data,
//            'url' => $url
//        ];
//        $header = $mt->getSignHeaders($config);
//
//        dump($header);
//
//        $res = $mt->curlPost($url, $data, 5, $header,'json');
//
//        $res = json_decode($res, true);
////

        dump($res);

        return 1;

        $c = new Ctrip();

        dump($c->getOrder(time()));

        exit();

//        $pa = '{"pageIndex":1,"pageSize":10,"orderId":"","orderStatus":"","sid":"","orderDateBegin":"2024-12-22 00:00:00","orderDateEnd":"2025-01-22 23:59:59","productType":"","commissionFlag":"","tab":1,"suballianceid":null,"orderSource":null}';
        $pa = '{"pageIndex":1,"pageSize":10,"orderId":null,"sid":null,"beginDate":"2024-12-23","endDate":"2025-01-23","dealBeginTime":null,"dealEndTime":null,"businessType":"ALL","orderStatus":"ALL","tag":"","environmentFrom":"","orderType":"ALL","clientFrom":"PC"}';

        $url = 'https://m.ctrip.com/restapi/soa2/14984/json/getAllianceOrderList';

// 设置 Cookie
        $cookie = 'GUID=09031040214795419564; nfes_isSupportWebP=1; UBT_VID=1737509555517.66fcxEz4l5LJ; _RF1=2408%3A8220%3A344%3Aacc0%3A6ccd%3Ab545%3A1e06%3A8f61; _RSG=hnqjBE8Dx0ANIe0ia2tfuB; _RDG=28cf7b81567f72264e2e553c9e35e54ab0; _RGUID=a03b3483-8bb7-4c6b-be29-dc292c028497; Session=smartlinkcode=U130026&smartlinklanguage=zh&SmartLinkKeyWord=&SmartLinkQuary=&SmartLinkHost=; login_type=0; ibulanguage=CN; ibulocale=zh_cn; cookiePricesDisplayed=CNY; MKT_CKID=1737512912833.sbk8w.e3e9; _ga=GA1.2.60790152.1737512917; _gid=GA1.2.1315603099.1737512917; ibu_h5_site=CN; ibu_h5_group=ctrip; ibu_h5_local=zh-cn; ibu_h5_local=zh-cn; ibu_h5_lang=zhcn; ibu_h5_curr=CNY; Hm_lvt_37b54c42b9dde393e60c88c1a84657cb=1737514242; Hm_lpvt_37b54c42b9dde393e60c88c1a84657cb=1737514242; HMACCOUNT=3900DEB2415B5BB9; Hm_lvt_576acc2e13e286aa1847d8280cd967a5=1737514395; Hm_lpvt_576acc2e13e286aa1847d8280cd967a5=1737514395; Hm_lvt_77b03ea75ddaa8a6bf817822b2af25f1=1737514400; Hm_lpvt_77b03ea75ddaa8a6bf817822b2af25f1=1737514578; Hm_lvt_a8d6737197d542432f4ff4abc6e06384=1737524884; Hm_lpvt_a8d6737197d542432f4ff4abc6e06384=1737524884; HMACCOUNT=3900DEB2415B5BB9; _jzqco=%7C%7C%7C%7C%7C1.7522607.1737512912775.1737512912775.1737524884326.1737512912775.1737524884326.0.0.0.2.2; _ga_5DVRDQD429=GS1.2.1737537466.2.1.1737537469.0.0.0; _ga_B77BES1Z8Z=GS1.2.1737537466.2.1.1737537469.57.0.0; MKT_Pagesource=H5; tangram_city_id=2; tangram_district_id=157; cticket=939ED63C6AC93155B00179778C4AE7D5EF6D8F7F496BB59673D9BF426BD9E2EC; login_uid=2FA226EA1758F92D3029BD69FF63A305; DUID=u=5F403D5B5F689024515F5EEC3ED778A4&v=0; AHeadUserInfo=VipGrade=0&VipGradeName=%C6%D5%CD%A8%BB%E1%D4%B1&UserName=&NoReadMessageCount=0; _PRO_sso_lat_assertion_=52574340b6db869cbeb0c104842675901a24566c8ea084869d2ce50172162f127a08cc6af4e16650b8a1c9bcfbbdd3ccafba97fefe4e05881fa52bb650aea2d296fa9ec327a5978fe46b5bde3b86d0096b4af3d4a7a1b3c26729fddddba28b064616b0fc365db0a1a873fd86104358b704a2ed327170c60af6bdf7738690b498; _PRO_sso_lat_assertion_signature_=81f059af8023ea3c542aa2ccd891a8bfc8ae74a6005eede013e344e6991db6e974e05ffa2dab53f5c45abf197a241e4567bcc19a0b9fbb4790e1f4cc15306e9a9813f7ba62881cb8f268e694203066d08ff009b5fa62823b3d29b5e3ddef1cbe2e1979df7fd886128c391af204693adba605e16ce253d95954c3b16ef55d6349; set_parentAllianceID=; environmentFrom=; envP=; atype=; _ubtstatus=%7B%22vid%22%3A%221737509555517.66fcxEz4l5LJ%22%2C%22sid%22%3A4%2C%22pvid%22%3A46%2C%22pid%22%3A%2210650006882%22%7D; union_ticket=eyJpc0xvZ2luIjp0cnVlLCJpc0FjdGl2YXRlIjp0cnVlfQ%3D%3D; _lizard_LZ=FEfs-v1noz5xh7UleScM8WKVZ2uP3YDCTNBAiIOdkwyQ4GjHpb+JqLRXrag90mt6; savePosition=0; _resDomain=https%3A%2F%2Fws-s.tripcdn.cn; _pd=%7B%22_o%22%3A11%2C%22s%22%3A19%2C%22_s%22%3A0%7D; Union=OUID=H5B2Bonline&AllianceID=5898222&SID=163951586&SourceID=2055&createtime=1737539783&Expires=1738144583396; MKT_OrderClick=ASID=5898222163951586&AID=5898222&CSID=163951586&OUID=H5B2Bonline&CT=1737539783397&CURL=https%3A%2F%2Fcontents.ctrip.com%2Fbuildingblocksweb%2Fspecial%2Fmembershipcard%2Findex.html%3F%26allianceid%3D5898222%26sid%3D163951586%26ouid%3DH5B2Bonline%26sourceid%3D2055%26Popup%3Dclose%26openapp%3D3&VAL={"pc_vid":"1737509555517.66fcxEz4l5LJ"}; _bfa=1.1737509555517.66fcxEz4l5LJ.1.1737539925686.1737539931530.4.87.10650046616';
        $headerArray =array("Content-type:application/json;charset='utf-8'",
            "Accept:application/json","Platform:pc",'Content-Length: ' . strlen($pa));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $pa);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);

        $response = curl_exec($ch);
        curl_close($ch);

// 处理响应数据
        $response_data = json_decode($response, true);
        $allianceOrderList = $response_data['allianceOrderList'];



        dump($response_data);
        dump(1);
        dump($response);
        halt($response);
//        $header['']
        $pa = '{"pageIndex":1,"pageSize":10,"orderId":"","orderStatus":"","sid":"","orderDateBegin":"2024-12-22 00:00:00","orderDateEnd":"2025-01-22 23:59:59","productType":"","commissionFlag":"","tab":1,"suballianceid":null,"orderSource":null}';
        $re = HttpService::request('https://m.ctrip.com/restapi/soa2/14984/json/queryProductOrders', $pa, $header);


        $ch = curl_init();

// 设置要访问的 URL
$url = 'https://m.ctrip.com/restapi/soa2/14984/json/queryProductOrders';
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_COOKIE, $cookie);

        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $pa);

// 或者使用 cookie 文件
// $cookieFile = "path/to/cookiefile.txt";
// curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

// 执行 cURL 请求并获取响应
$response = curl_exec($ch);
if ($response === false) {
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo 'Response: ' . $response;
}

// 关闭 cURL 会话
curl_close($ch);

        halt(1);
        $tb = new Tbk();

//        dump($tb->getOrder(strtotime('2025-01-16 00:05:29')));
        dump($tb->test());
//        dump($tb->getRefundOrder(strtotime('2025-01-16 00:05:29')));

        return 1;
        exit();

        $ta = new \app\common\command\Task();

        dump($ta->test());

        return 1;

// APP登录成功后获得的identityToken
        $identityToken = 'eyJraWQiOiJyQlJmVm1xc2puIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLnFpZmFuLnl1bmZ1eWUiLCJleHAiOjE3Mzc1MzI1MTQsImlhdCI6MTczNzQ0NjExNCwic3ViIjoiMDAxMzg2LmY1ZGYyMDA3NWNkYjRlYzJiZWU5ZGY2ZjgzNTc4YjVhLjA3NTUiLCJjX2hhc2giOiJXZlgwY3FqakluOS1jQ0lzbFUzY01RIiwiZW1haWwiOiJhbnpob25nZmFuM0AxNjMuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1dGhfdGltZSI6MTczNzQ0NjExNCwibm9uY2Vfc3VwcG9ydGVkIjp0cnVlLCJyZWFsX3VzZXJfc3RhdHVzIjoyfQ.Mxmkgj3X8q6PhTf-6q1401lMN3bm-yIiFQxM9X7QwiYMG15X3XK12I9GZBtogJLcL8S35U-Gd9LYnfJpX_vQG3INX4nMPlEBGCPeQWrifJZ9eezUt_LcmljeZv2Bdbar05KNgRxLx2Gc137ajxgAEU09L70c5DSct_LrrM_WIg4XeteO9VnpBZgVtDWvAn24wIEw8gHxwy_5Qo6bNwLNzunc8uY9hQDM-sZ5Jp_FHnQbOz-9zRcuuF8Xikufj-X4foDAGQUatdDGcwI8pdpAktcfsuebRkn8lFAflk2iszJcik9g4ArDDvd7z5sITB9wEfVemyYHcwUZDuJ7_1ZvOQ';

// 调用苹果接口获取JWKS
        $apiResponse = file_get_contents('https://appleid.apple.com/auth/keys');
        $jwkSet = json_decode($apiResponse, true);
        if (!is_array($jwkSet)) {
            exit("Get JWK failed");
        }

// 将JWKS转换为公钥
        try {
            $pubKeys = JWK::parseKeySet($jwkSet);
        } catch (\Exception $e) {
            exit("Parse key set failed:" . $e->getMessage());
        }

// 使用公钥对JWT进行检验
        try {
            $payload = JWT::decode($identityToken, $pubKeys);
        } catch (\Exception $e) {
            exit("Decode JWT failed:" . $e->getMessage());
        }

// 若检验通过，会得到JWT里的payload信息
       dump($payload);
       dump($payload->sub);//openid
       dump($payload->email);
       dump($payload->aud);//包名


//        $user = UserModel::find(16006);
//
//        $param = [];
//        $param['type'] = 'deposit';
//        NoticeEvent::send($param, $user);
//        $pay= Pay::where('id',807)->find();
//
//        dump($pay->toArray());
//        $event = new ThirdRechargeEvent();
//       $re=  $event->pay($pay);
//
//       dump($re);
       return 1;
        $tui = new Tui();
        $user = UserModel::find(16006);
//        $param['app_task_id'] = 434;
//        $param['bb_id'] = 1763472;
//        dump($tui->getAppDetail());
//
//        $tui = new Tui();
        $re = $tui->getPzs();
//        dump($re);

//        $jd = new Jd();

//        dump($jd->parseContent('【京东】https://3.cn/2aLXV-0u「贝琪电钢琴」点击链接直接打开',$user,'ff'));
//        dump($jd->getOrder(3,strtotime('2025-01-06 18:19:48')));
//        dump($jd->getOrder(3,time()));
//        dump($jd->parseContent('闪迪（SanDisk）64GB USB3.',$user,'ff'));

        return 1;;

        $logs = UserMoneyLogModel::where('user_id', 16152)->order('create_time asc')->select();


//        dump($logs->toArray());

        $num = 0;
        foreach ($logs as $index => $log) {

            if ($index > 1) {

                if ($logs[$index - 1]['after'] != $log['before']) {
//                    dump($logs[$index-1]->toArray());
//                    dump($log['id']);
                    $num += $logs[$index - 1]['money'];
                    dump($logs[$index - 1]['id'] . '-' . $logs[$index - 1]['money']);
//                    dump($log->toArray());
                }

            }
        }


        dump($num);

        return 1;

        $userCashs = UserCash::where('status', 1)->whereTime('create_time', '>', '-7 month')->select();


        foreach ($userCashs as $userCash) {

            $userCash['agent_id'] = $userCash['user']['agent_id'];
            Db::name('user_cash')->where('id', $userCash['id'])->update(['agent_id' => $userCash['user']['agent_id']]);
        }

//        dump(BillEvent::agentMonth());
//
//        $t = new Tui();
//
//        dump($t->getAppDetail());
//        dump($t->getAllTask());


        return '1';
////        $re = $oa->send('oAAIg6w_C0wy7_rmcb3VahTohD6s', 'WsQr3fXxkekM039dy0rYtP_G2Zoqf5j_y66Rvw7RujA', $oa_data, '');
//        dump($re);
//        exit();
        // 微尘

        // 微尘

//        dump(explode('X', '661616691X10X100'));exit();
//
//        $third = ThirdRechargeModel::where('name_type', '国家电网电费')
////            ->where('guide_price', '<', $order['amount'] - $order['part_amount'])
//            ->order('guide_price DESC')
//            ->find();
//
//        dump($third->toArray());
//        exit();
//        $t = new ThirdRecharge();
//
//        dump($t->info());
//        exit();
        $user = UserModel::find(16006);
        $tbk = new Pdd();
//        $re = $tbk->getOrder(time(), 3600);
//        $re = $tbk->searchByKeyword('优贝舒超薄透气纸尿裤拉拉裤全包一体式新生婴儿宝宝尿不湿试用装',$user,1);
//        $re = $tbk->parseContent('E9T2ozXJmr9vgXzRwfDezP92PENEmxR7Aw_JgRZfWcyX',$user);
        $tbk = new Tbk();
//        $re = $tbk->getOrder(time(), 3600);
        $re = $tbk->searchByKeyword('优贝舒', $user, 1);

        dump($re);
        return '1';
        exit();


        $logs = Db::name('user_money_log')->order('id desc')->select();



        $show_type = UserMoneyLogModel::$show_type;

        foreach ($logs as $log) {
            if (isset($show_type[$log['type']]) && $show_type[$log['type']] == '展业收益') {
                $is_work = 1;
            } elseif (isset($show_type[$log['type']]) && $show_type[$log['type']] == '邀请奖励') {
                $is_work = 2;
            } elseif (isset($show_type[$log['type']]) && $show_type[$log['type']] == '管理奖励') {
                $is_work = 3;
            } else {
                $is_work = 0;
            }

            Db::name('user_money_log')->where('id', $log['id'])->update(['is_work' => $is_work]);
        }

        return '1';

        dump(count($logs));
        exit();




        $tui = new Tui();
        $user = UserModel::find(16006);
        $param['app_task_id'] = 434;
        $param['bb_id'] = 1763472;
        dump($tui->getAppDetail());
        exit();
//        dump($tui->getPzs());
//        dump($tui->getTaskInfo());
//        dump($tui->getBb());
        dump($tui->subPz($param, $user));
//        dump($tui->apply($param,$user));

        exit();
//        PddGoodModel::where('user_id', 1)
////                ->whereTime('update_time', '>', '-1 day')
//                ->whereNull('check_ok_time')
////            ->whereOr('check_ok_time','>',time_format('today'))
//                //`check_ok_time` > '2024-12-27 00:00:00'
//            ->whereRaw('`check_ok_time` > \''.time_format('today').'\' OR `check_ok_time` IS NULL')
////            ->whereTime('check_ok_time', '>', 'today')
//            ->order('id DESC')->limit(50)
//            ->where('status', 1)->select();
//        return 'ok';
//        exit();
//        $reply = WechatReplyModel::where('main_event', 'all')->where('status', 1)->find();
//        dump($reply);
//        dump(IpPool::task());
//        exit();
//        $str = 'N3500000078';
//        $num = 853;
//
//
//
//        for ($i = 0; $i < 100; $i++) {
//            echo $str.$num.'<br>';
//            $num++;
//        }
//
//        return 'ok';

        $jd = new Jd();

        dump($jd->getPromotio1n());

        return;
        $pdd = new Pdd();;
////
        dump($pdd->getOrderByUpdate(time() - 3600 * 3));
        return 'pl';
        exit();
//        return'p';
//        exit();
//        exit();
//        $user = UserModel::find(36);
//        $user = UserModel::find(36);
        $user = UserModel::find(197);
//        $user = UserModel::find(61);
//        dump($pdd->getOrderByUpdate(time(),86000));
        dump($pdd->parseContent('https://mobile.yangkeduo.com/goods2.html?ps=s7AYzL9L0G', $user));
//        dump($pdd->parseContent('https://mobile.yangkeduo.com/goods2.html?ps=PyXrrjXo3m',$user));
//        dump($pdd->parseContent('https://mobile.yangkeduo.com/goods1.html?ps=veAhhrByz4',$user));
        exit();


    }


}
